/*
package com.isoft.listener;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.monitor.FileAlterationMonitor;
import org.apache.commons.io.monitor.FileAlterationObserver;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.io.File;

*/
/**
 * 定义一个对象实现ApplicationRunner接口，为了让文件监听在项目启动后直接执行
 *//*

@Component
@Slf4j
public class ApplicationRunnerForFile implements ApplicationRunner {
    private String path="D://file";
    @Override
    public void run(ApplicationArguments args) throws Exception {
        try {
            FileAlterationObserver fileAlterationObserver =
                    new FileAlterationObserver(new File(path));
            FileListener fileListener = new FileListener();
            fileAlterationObserver.addListener(fileListener);
            FileAlterationMonitor monitor =
                    new FileAlterationMonitor(1000, new FileAlterationObserver[]{fileAlterationObserver});
            monitor.start();
        }catch (Exception e){
            log.error("文件监听启动失败");
            e.printStackTrace();
        }
    }
}
*/
